const user = {
	state: {
		userToken:uni.getStorageSync('userToken')||'',
		userInfo:uni.getStorageSync('userInfo')||'',
		APPTheme:uni.getStorageSync('APPTheme')||'theme-light',//app主题主题默认为浅色theme-light，theme-dark为深色
		rememberPassword:uni.getStorageSync('rememberPassword')||'',//记住用户密码
	},
	mutations: {
		SET_userToken:(state, userToken)=>{
			state.userToken=userToken
		},
		SET_userInfo:(state, userInfo)=>{
			state.userInfo=userInfo
		},
		SET_APPTheme:(state, APPTheme)=>{
			state.APPTheme=APPTheme
		},
		SET_rememberPassword:(state,rememberPassword)=>{
			state.rememberPassword=rememberPassword
		},
		REMOVE_rememberPassword:(state,rememberPassword)=>{
			state.rememberPassword=rememberPassword
		},
	},

	actions: { //异步操作mutation
		remove_userInfo({commit}, userInfo) {
			uni.removeStorageSync('userInfo');
			commit('SET_userInfo', userInfo)
		},
		set_userToken({commit}, userToken) {
			uni.setStorageSync('userToken', userToken);
			commit('SET_userToken', userToken)
		},
		set_userInfo({commit}, userInfo) {
			uni.setStorageSync('userInfo', JSON.stringify(userInfo));
			commit('SET_userInfo', JSON.stringify(userInfo))
		},
		set_APPTheme({commit}, APPTheme) {
			uni.setStorageSync('APPTheme', APPTheme);
			commit('SET_APPTheme', APPTheme)
			//#ifdef H5
			document.documentElement.setAttribute('lz-theme', APPTheme);
			//#endif
		},
		set_rememberPassword({commit},rememberPassword){
			uni.setStorageSync('rememberPassword', rememberPassword);
			commit('SET_rememberPassword', rememberPassword)
		},
		remove_rememberPassword({commit},rememberPassword){
			uni.removeStorageSync('rememberPassword');
			commit('REMOVE_rememberPassword', rememberPassword)
		}
	}
}

export default user
